package com.ihr360.insurance.service;

import com.ihr360.commons.vo.PageData;
import com.ihr360.excel.entity.ExportParams;
import com.ihr360.excel.vo.CustomSpreadSheetValidateResult;
import com.ihr360.excel.vo.ImportRequest;
import com.ihr360.excel.vo.SpreadSheetValidatorRequest;
import com.ihr360.insurance.entity.request.MonthlyLedgerRequest;
import com.ihr360.insurance.entity.response.LedgerResponse;
import com.ihr360.insurance.entity.vo.StaffBenefitVo;
import com.ihr360.insurance.model.dto.ledger.MonthlyLedger;
import com.ihr360.insurance.model.meta.DynamicHeaderCell;
import com.ihr360.insurance.model.meta.DynamicRowCell;
import com.ihr360.insurance.model.vo.MonthlyLedgerVo;
import com.ihr360.rest.service.SimpleRestService;

import javax.servlet.ServletOutputStream;
import java.util.List;
import java.util.Map;

public interface MonthlyLedgerService extends SimpleRestService<MonthlyLedger, Long> {

    /**
     * 获取台账数据
     *
     * @param companyId
     * @param userId
     * @param req
     * @return
     */
    PageData<MonthlyLedgerVo> getLedgerList(String companyId, String userId, MonthlyLedgerRequest req);

    /**
     * 获取系统级别的所有社保公积金方案中的完整的有效表头数据信息
     *
     * @return
     */
    List<DynamicHeaderCell> getSIHFTotalHeaderCell();

    /**
     * 获取指定台账中的指定员工
     *
     * @param companyId
     * @param useId
     * @param ledgerYear
     * @param ledgerMonth
     * @param staffIds
     * @return <staffId,<cellId,cellValue>>
     */
    Map<String, Map<String, Double>> getStaffLedger(String companyId, String useId,
                                                    Integer ledgerYear, Integer ledgerMonth,
                                                    List<String> staffIds);

    /**
     * 获取月度台账中包含的全部员工id
     *
     * @param companyId
     * @param useId
     * @param ledgerYear
     * @param ledgerMonth
     * @return
     */
    List<String> getStaffIds(String companyId, String useId, Integer ledgerYear, Integer ledgerMonth);

    /**
     * 为社保公积金月度台账添加人员
     * 保证StaffBenefitVo中，社保或者公积金至少一项有效
     *
     * @param companyId
     * @param userId        当前登录的web用户id
     * @param staffBenefits
     * @param ledgerYear
     * @param ledgerMonth
     * @return
     */
    LedgerResponse addLedgerStaff(String companyId, String userId, List<StaffBenefitVo> staffBenefits, Integer ledgerYear, Integer ledgerMonth);


    /**
     * 删除某个月度台账的数据
     *
     * @param companyId
     * @param userId
     * @param ledgerYear
     * @param ledgerMonth
     */
    void deleteLedger(String companyId, String userId, Integer ledgerYear, Integer ledgerMonth);

    /**
     * 删除月度台账的部分员工
     *
     * @param companyId
     * @param userId
     * @param ledgerYear
     * @param ledgerMonth
     * @param staffIds
     */
    void deleteLedgerStaff(String companyId, String userId, Integer ledgerYear, Integer ledgerMonth, List<String> staffIds);

    /**
     * 保存修改后的台账单元格数据
     *
     * @param userId 用于权限验证
     * @param ledgerCells
     */
    void saveLedgerCells(String userId, Map<Long, Map<String, DynamicRowCell>> ledgerCells);

    /**
     * 重新核算台账数据
     *
     * @param companyId
     * @param userId
     * @param ledgerYear
     * @param ledgerMonth
     * @return
     */
    LedgerResponse calculateLedgers(String companyId, String userId, Integer ledgerYear, Integer ledgerMonth);

    /**
     * 获取导出的数据
     * @param companyId
     * @param userId
     * @param req
     * @param departmentFullNames
     * @return
     */
    ExportParams<List<Object>> getExportData(String companyId, String userId, MonthlyLedgerRequest req, Map<Long, String> departmentFullNames);

    /**
     * 下载模板
     *
     * @param companyId
     * @param ledgerYear
     * @param ledgerMonth
     * @param outputStream
     */
    void downloadTemplate(String companyId, Integer ledgerYear, Integer ledgerMonth, ServletOutputStream outputStream);

    /**
     * 校验导入的员工台账数据
     *
     * @param companyId
     * @param userId
     * @param ledgerYear
     * @param ledgerMonth
     * @param validatorRequest
     * @return
     */
    CustomSpreadSheetValidateResult validateExcelData(String companyId, String userId,
                                                      Integer ledgerYear, Integer ledgerMonth,
                                                      SpreadSheetValidatorRequest validatorRequest);

    /**
     * 导入员工台账数据
     *
     * @param companyId
     * @param userId
     * @param ledgerYear
     * @param ledgerMonth
     * @param importRequest
     */
    void importExcel(String companyId, String userId, Integer ledgerYear,
                     Integer ledgerMonth, ImportRequest importRequest);
}
